package cn.maszy.action.systemsetting;

import cn.maszy.common.BaseAction;
import cn.maszy.common.Pager;
import cn.maszy.model.systemsetting.B_T_Ufp_Role;
import cn.maszy.service.systemsetting.B_T_Ufp_RoleService;
import net.sourceforge.stripes.action.SessionScope;
import org.springframework.beans.factory.annotation.Autowired;

@SessionScope
public class roleAction extends BaseAction<B_T_Ufp_Role> {
	/*
	 * 角色创建
	 */
	private static final long serialVersionUID = 6179604301571294802L;
	private B_T_Ufp_Role b_T_Ufp_Role;
	@Autowired
	private B_T_Ufp_RoleService b_T_Ufp_RoleService;
	private String checkIds;
	/*********************class set/get****************************/
	public B_T_Ufp_Role getB_T_Ufp_Role() {
		return b_T_Ufp_Role;
	}

	public void setB_T_Ufp_Role(B_T_Ufp_Role b_T_Ufp_Role) {
		this.b_T_Ufp_Role = b_T_Ufp_Role;
	}

	public String getCheckIds() {
		return checkIds;
	}
	
	public void setCheckIds(String checkIds) {
		this.checkIds = checkIds;
	}
	/*******************STRUTS ACTION METHOD*************************/
	/**
	 * 
	 * @Author:Arthur
	 * @Time:2012-10-17
	 * @Parameter:删除一条记录
	 * @Return:String
	 * @Throws
	 */
	public String roleDel() throws Exception{
		int i=b_T_Ufp_RoleService.delete(checkIds);
		if(i>0)
		return ajaxForwardSuccess(getText("msg.operation.success"), "RoleList","", "forward", "systemsetting/RoleList");
		return ajaxForwardError(getText("msg.operation.failure"));
	}
	/**
	 * @Author:Arthur
	 * @Time:2012-10-17
	 * @Parameter:查询单条记录
	 * @Return:String
	 * @Throws
	 */
	public String roleDetail() throws Exception{
		if(b_T_Ufp_Role==null){
			b_T_Ufp_Role=b_T_Ufp_RoleService.selectOne("");
		}else{
			b_T_Ufp_Role=b_T_Ufp_RoleService.selectOne(b_T_Ufp_Role.getRoleid());
		}
		return SUCCESS;
	}
	/**
	 * 
	 * @Author:Arthur
	 * @Time:2012-10-17
	 * @Parameter: 查询list
	 * @Return:String
	 * @Throws
	 */
	public String roleList() throws Exception{
		pager = new Pager<B_T_Ufp_Role>(pageNum, numPerPage,orderField,orderDirection);
		pager= b_T_Ufp_RoleService.selectList(b_T_Ufp_Role,pager);
		return SUCCESS;
	}
	/**
	 * @Author:Arthur
	 * @Time:2012-10-17
	 * @Parameter:新增/修改
	 * @Return:String
	 * @Throws
	 */
	 
	public String roleUpdate(){
		int i=b_T_Ufp_RoleService.update(b_T_Ufp_Role);
		if(i>0)
			//目前只有点击提交后关闭
			//return ajaxForwardSuccess(getText("msg.operation.success"), "adminList", "closeCurrent", "investment/adminList");
		//保存不关闭暂时没做
		return ajaxForwardSuccess(getText("msg.operation.success"), "RoleList","", "forward", "systemsetting/RoleList");
		return ajaxForwardError(getText("msg.operation.failure"));
	}
}
